package com.ly.web.controller.erp;

import java.util.List;

import com.ly.heart.domain.KingBomDetailEntity;
import com.ly.heart.domain.dto.KingBomDto;
import com.ly.heart.domain.dto.KingBomProductDto;
import com.ly.heart.service.IKingBomService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ly.common.annotation.Log;
import com.ly.common.core.controller.BaseController;
import com.ly.common.core.domain.AjaxResult;
import com.ly.common.enums.BusinessType;
import com.ly.heart.domain.KingBomEntity;
import com.ly.common.utils.poi.ExcelUtil;
import com.ly.common.core.page.TableDataInfo;

import javax.annotation.Resource;

/**
 * BOM清单Controller
 * @author wutao
 * @date 2024-07-26
 */
@Api (value = "KingBom", tags = "BOM清单")
@RestController
@RequestMapping ("/heart/KingBom")
public class KingBomController extends BaseController {

    @Resource
    private IKingBomService kingBomEntityService;

    /**
     * 查询BOM清单列表
     */
    @PreAuthorize ("@ss.hasPermi('heart:KingBom:list')")
    @GetMapping ("/list")
    @ApiOperation ("查询BOM清单列表")
    public AjaxResult list (KingBomEntity kingBomEntity) {
        return kingBomEntityService.selectKingBomEntityList ( kingBomEntity );
    }

    /**
     * BOM展开操作
     * @return
     */
    @PostMapping ("expand")
    @ApiOperation ("BOM展开")
    @Log (title = "BOM展开")
    public AjaxResult expand (@RequestBody KingBomProductDto kingBomProductDto) {
        List<KingBomDetailEntity> expand = kingBomEntityService.expand ( kingBomProductDto );
        return AjaxResult.success ( expand );
    }

    /**
     * 获取BOM清单详细信息
     */
    @PreAuthorize ("@ss.hasPermi('heart:KingBom:query')")
    @GetMapping (value = "/{id}")
    @ApiOperation ("获取BOM清单详细信息")
    public AjaxResult getInfo (@PathVariable ("id") String id) {
        return AjaxResult.success ( kingBomEntityService.selectKingBomEntityById ( id ) );
    }

    @RequestMapping ("queryList")
    public AjaxResult queryList (KingBomEntity kingBomEntity) {
        AjaxResult ajaxResult = kingBomEntityService.queryList ( kingBomEntity );
        return ajaxResult;
    }

    /**
     * 暂存BOM清单
     */
    @PreAuthorize ("@ss.hasPermi('heart:KingBom:add')")
    @Log (title = "暂存BOM清单", businessType = BusinessType.INSERT)
    @PostMapping ("draft")
    @ApiOperation ("暂存BOM清单")
    public AjaxResult draft (@RequestBody KingBomDto kingBomEntity) {
        return kingBomEntityService.draft ( kingBomEntity );
    }

    /**
     * 新增BOM清单
     */
    @PreAuthorize ("@ss.hasPermi('heart:KingBom:add')")
    @Log (title = "提交BOM清单", businessType = BusinessType.INSERT)
    @PostMapping ("submit")
    @ApiOperation ("提交BOM清单")
    public AjaxResult submit (@RequestBody KingBomEntity kingBomEntity) {
        return kingBomEntityService.submit ( kingBomEntity );
    }

    /**
     * 修改BOM清单
     */
    @PreAuthorize ("@ss.hasPermi('heart:KingBom:edit')")
    @Log (title = "BOM清单", businessType = BusinessType.UPDATE)
    @PutMapping
    @ApiOperation ("修改BOM清单")
    public AjaxResult edit (@RequestBody KingBomDto kingBomDto) {
        return kingBomEntityService.updateKingBomEntity ( kingBomDto );
    }

    /**
     * 删除BOM清单
     * 伪删除
     */
    @PreAuthorize ("@ss.hasPermi('heart:KingBom:remove')")
    @Log (title = "BOM清单", businessType = BusinessType.DELETE)
    @DeleteMapping ("/{ids}")
    @ApiOperation ("删除BOM清单")
    public AjaxResult remove (@PathVariable String[] ids) {
        return kingBomEntityService.updateByDelete ( ids );
    }
}
